<?php include_once('header.php');?>

<script type="text/javascript" charset="utf-8">

$(function(){
        $('#get-menu').delegate(
            'a.dropdown-toggle','mouseover',function(){
                if(!$(this).next().length > 0){
                    get_menu($(this).attr('id'));
                }
                $(this).dropdown();
            } 
        );

        $('li.dropdown-submenu').delegate(
            'a.dropdown-toggle','mousedown',function(){
                console.log($this);
                location.href=$(this).attr('href');
            }
        );


    $('#markdown').find('pre code').each(function(i, e) {
            hljs.highlightBlock(e);
    });
});

function selfto(it){
    location.href=it.href;
}

function get_menu(id){
    var menu,path;
    amenu = $('#'+id)
    path = amenu.attr('href');
    (function(amenu,path){
    $.get(
            "/menu.php"
            ,{u:path}
            ,function(data){
                zimenu = $('#'+id);
                menu = '<ul class="dropdown-menu">';
                li = '';
                $.each(data.dirs,function(i,item){
                    li += '<li  class="dropdown-submenu"> <a href="'+item.path+'" data-target="#"  tabindex="-1" class="dropdown-toggle" id="'+item.id+'" onclick="selfto(this)"> '+item.title+'</a> </li>'
                });
                li += '<li class="divider"></li>'
                $.each(data.files,function(i,item){
                    li += '<li> <a href="'+item.path+'"> '+item.title+'</a> </li>'
                });
                menu += li+'</ul>';
                zimenu.after(menu);
            }  
    )
    })(amenu,path);
}
    
</script>

<div class="container" id='path'>

<div id='get-menu' class="dropdown" style='float:left;padding-top:4px;'>
    [ <a href="?s" target="_blank">源文</a> ]&nbsp;&nbsp;
    [ <a href="?h" target="_blank">HTML</a> ]&nbsp;&nbsp;
    [ <a href="//localhost:8084/<?php echo $url ?>" target="_blank">HTML2</a> ]&nbsp;&nbsp;
    [ <a class="dropdown-toggle" id="dropdownMenu" role="button" data-toggle="dropdown" data-target="#" href="/">
        菜单
        <b class="caret"></b>
    </a> ]
   &nbsp;&nbsp;&nbsp;&nbsp; 
</div>
<ul class="breadcrumb" style='background:none;'>
	<?php 
	foreach($path as $p){
		echo '<li><a href="'.GLOBAL_URL.'index.php'.$p['path'].'">'.$p['title'].'</a><span class="divider">/</span></li>';
	}
	?>
	<li class="active"> <?php echo $title; ?></li>
</ul>
</div>
<div class="container ">
    <div class="markdown box-shadow" id="markdown" > 
        <?=$content?>
    </div> <!-- end right --> 
    <?php 
    include_once('sides.php');
     ?>
</div> <!-- end container -->
<?php //include_once('footer.php');?>
